<template>
  <div>
    <common-head title="支付" />
    <div class="wrap">
      <van-contact-card
        :type="type"
        :name="currentOrder.contact.name"
        :tel="currentOrder.contact.tel"
        @click="onEdit"
      />
      <!-- 购买商品 -->
      <div class="items">
        <div
          class="shang"
          v-for="item in currentOrder.items"
          :key="item.id">
          <img :src="item.pic" alt />
          <div class="tlite">
            <h3>{{item.name | subStr(14)}}</h3>
            <p class="tlite-p">{{item.characteristic | subStr(35)}}</p>
            <div class="pic">
              <p>
                {{item.minPrice | currency('￥')}}
                <span>{{item.originalPrice | currency('￥')}}</span>
              </p>
              <p class="nums">x {{item.num}}</p>
            </div>
          </div>
        </div>
      </div>
      <!-- /购买商品 -->
    </div>
    <van-submit-bar :price="currentOrder.total*100" button-text="提交订单" @submit="onSubmit" />
  </div>
</template>

<script>
import CommonHead from '@components/CommonHead'
import { currency, subStr } from '@/filters'
import { mapState } from 'vuex'
export default {
  methods: {
    onEdit () {
      // 选择联系人中 选择联系人 进入联系人列表
      this.$router.push('/contactList')
    },
    onSubmit () {
      alert('1')
    }
  },
  computed: {
    ...mapState({
      currentOrder: state => state.order.currentOrder
    }),
    type () {
      // 选择联系人装填
      if (this.currentOrder.contact.name) {
        return 'edit'
      } else {
        return 'add'
      }
    }
  },
  components: {
    CommonHead
  },
  filters: {
    currency,
    subStr
  }
}
</script>

<style lang="scss" scoped>
.wrap{
  margin-top: 46px;
  margin-bottom: 50px;
}
.shang{
  display: flex;
  background: rgb(243,245,247);
  height: 150px;
  margin-top: 7px;
  img{
    width: 150px;
  }
  .tlite{
    flex: 1;
    margin-left: 2px;
    background: #fff;
    padding-right: 10px;
    position: relative;
    h3{
      font-size: 18px;
      margin:5px 0;
      padding: 0;
    }
    &-p{
      margin-right: 15px;
      color: #666;
    }
    .pic{
      display: flex;
      justify-content: space-between;
      width: 93%;
      position: absolute;
      bottom: 5px;
      left: 0;
      p{
        margin: 0;
        color: rgb(255, 0, 76);
        span{
          margin-left: 5px;
          font-size: 14px;
          color: #666;
          text-decoration: line-through;
        }
      }
      .nums{
        color: #666;
      }
    }
  }
}
</style>
